<?php 

function ListPromotions()
{
  global $dbsql,$language,$child;
  
    if($child=="hotel")
    {
        $tablebo    = "tblhotel";
    }else
    {
        $child       = 'tour';
        $tablebo    = "tblsettour";
    }
    $sql_select = "select pro.*,bo.cName from tblpromotions as pro JOIN $tablebo as bo ON 
                    pro.iParentId=bo.iId and pro.cType='$child' and bo.cLanguage='$language' order by pro.iOrder";
    return $dbsql->load($sql_select);  
}

function ListOptionParent()
{
    global $dbsql,$language,$child;
    if($child=="hotel")
    {
        $tablebo    = "tblhotel";
    }else
    {
        $child      = 'tour';
        $tablebo    = "tblsettour";
    }
    
    $sql_select = "select bo.cName,bo.iId from $tablebo as bo  where bo.iId not in
                    (select iParentId from tblpromotions as pro where pro.cType='$child' )
                    and bo.cLanguage='$language' order by bo.cUrlString";
    $rs         = $dbsql->query($sql_select);
    $options    = '';
    while($result   = $dbsql->fetch_array($rs))
    {
        $options    .= "<option value='".$result['iId']."'>".$result['cName']."</option>";
    }
    return $options;    
}

function getNameParent($idP,$child)
{
    global $dbsql,$language;
    
    if($child=="hotel")
    {
        $tablebo    = "tblhotel";
    }else
    {
        $child      = 'tour';
        $tablebo    = "tblsettour";
    }
    
    $sql_select = " select cName from $tablebo where iId=$idP";
    $result     = $dbsql->query_fetch($sql_select);
    return $result['cName'];
}
?>